#!/bin/bash

#Debian's nc needs a little help communicating with SBS..

SCIp='127.0.0.1'
CLIPort='9090'


mync () {
  while read data
  do
    echo "$data\nexit\n"
    printf "$data\nexit\n" | nc -w 3 $SCIp $CLIPort
  done
}



echo Setting blocks:
echo srvrpowerctrl setblock I_really_dont_want_to_be_bothered viacli | mync
echo srvrpowerctrl setblock the_music_is_too_beautiful_to_end viacli | mync
echo .
echo Attempting a shutdown:
echo srvrpowerctrl shutdown time_to_go_to_bed viacli | mync
echo .
echo Clearing blocks:
echo srvrpowerctrl clearblock nada viacli | mync
echo srvrpowerctrl clearblock nada viacli | mync


